package com.yang.bean.resource;

import java.io.InputStream;

/**
 * @Description: 流处理的实现类
 * @author: Yang Qiang
 * @create: 2021-11-08 21:32
 */
public class ClassPathResource implements Resource {
    // 文件的路径
    private String location;

    public ClassPathResource(String location) {
        this.location = location;
    }

    /**
     * 获得流信息
     * @return
     */
    @Override
    public InputStream getInputStream() {
        // 通过构造器, 然后把路径转化为响应的流
        return this.getClass().getClassLoader().getResourceAsStream(location);
    }
}
